﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Typing_GUI.CLASS
{
    public class CKeyboard
    {
        
        //Hàm kiểm tra phím có đang mở Caps Lock hay không.
        public static bool CheckCapsLock()
        {
            if (Control.IsKeyLocked(Keys.CapsLock))
                return true;
            return false;
        }

        //Hàm vẽ phím với vị trí tương ứng
        public static void DrawKey(Point p,int width,int height, PaintEventArgs e, Brush brush,int pos)
        {
         
            e.Graphics.DrawRectangle(new Pen(brush, 3), p.X +pos * 6 + pos * 32 + pos, p.Y, width, height );
        
        }
        //Hàm trả về vị trí của phím
        public static void  GetKey(char letter,ref int line,ref int pos)
        {
           
            switch (letter)
            {
                case '`':case '~':
                    line = 0; pos = 0;break;
                case '1':case '!':
                    line = 0; pos = 1;break;
                case '2':case '@':
                    line = 0; pos = 2;break;
                case '3':case '#':
                    line = 0; pos = 3;break;
                case '4':case '$':
                    line = 0; pos = 4;break;
                case '5':case '%':
                    line = 0; pos = 5;break;
                case '6':case '^':
                    line = 0; pos = 6;break;
                case '7':case '&':
                    line = 0; pos = 7;break;
                case '8':case '*':
                    line = 0; pos = 8;break;
                case '9':case '(':
                    line = 0; pos = 9;break;
                case '0':case ')':
                    line = 0; pos = 10;break;
                case 'q':case 'Q':
                    line = 1; pos = 0;break;
                case 'w':case 'W':
                    line = 1; pos = 1;break;
                case 'e':case 'E':
                    line = 1; pos = 2;break;
                case 'r':case 'R':
                    line = 1; pos = 3;break;
                case 't':case 'T':
                    line = 1; pos = 4;break;
                case 'y':case 'Y':
                    line = 1; pos = 5;break;
                case 'u':case 'U':
                    line = 1; pos = 6;break;
                case 'i':case 'I':
                    line = 1; pos = 7;break;
                case 'o':case 'O':
                    line = 1; pos = 8;break;
                case 'p':case 'P':
                    line = 1; pos = 9;break;
                case '[':case '{':
                    line = 1; pos = 10;break;
                case ']':case '}':
                    line = 1; pos = 11; break;
                case '\\':case '|':
                    line = 1; pos = 12; break;
                case 'a':case 'A':
                    line = 2 ;pos = 0; break;
                case 's':case 'S':
                    line = 2; pos = 1; break;
                case 'd':case 'D':
                    line = 2; pos = 2; break;
                case 'f':case 'F':
                    line = 2; pos = 3; break;
                case 'g':case 'G':
                    line = 2; pos = 4; break;
                case 'h':case 'H':
                    line = 2; pos = 5; break;
                case 'j':case 'J':
                    line = 2; pos = 6; break;
                case 'k':case 'K':
                    line = 2; pos = 7; break;
                case 'l':case 'L':
                    line = 2; pos = 8; break;
                case ':':case ';':
                    line = 2; pos = 9; break;
                case '"':case '\'':
                    line = 2; pos = 10; break;
                case 'z':case 'Z':
                    line = 3; pos = 0; break;
                case 'x':case 'X':
                    line = 3; pos = 1; break;
                case 'c':case 'C':
                    line = 3; pos = 2; break;
                case 'v':case 'V':
                    line = 3; pos = 3; break;
                case 'b':case 'B':
                    line = 3; pos = 4; break;
                case 'n':case 'N':
                    line = 3; pos = 5; break;
                case 'm':case 'M':
                    line = 3; pos = 6; break;
                case '<':case ',':
                    line = 3; pos = 7;break;
                case '>':case '.':
                    line = 3; pos = 8;break;
                case '/':case '?':
                    line = 3; pos = 9; break;
                case ' ':
                    line = 3; pos = -1;
                    break;
                default:
                    break;
            }
            
            
        }
        
    }
}
